package routers

import (
	"ginBolg/api"
	"ginBolg/middleware"
	"github.com/gin-contrib/sessions"
	"github.com/gin-contrib/sessions/cookie"
)

var store = cookie.NewStore([]byte("HyCD89g3VDJ9646BFGEh37GfJ"))

func (router RouterGroup) UserRouter() {
	app := api.ApiGroupApp.UserApi
	router.Use(sessions.Sessions("sessionid", store))
	router.GET("users", middleware.JwtAuth(), app.UserListView)
	router.POST("email_login", app.EmailLoginView)
	router.POST("login", app.QQLoginView)
	router.POST("user_create", middleware.JwtAdmin(), app.UserCreateView)

	router.PUT("user_role", middleware.JwtAdmin(), app.UserRoleUpdate)
	router.PUT("user_password", middleware.JwtAuth(), app.UserPasswordUpdate)
	router.POST("logout", middleware.JwtAuth(), app.UserPasswordUpdate)
	router.DELETE("users", middleware.JwtAdmin(), app.UserRemoveView)
	router.POST("user_bind_email", middleware.JwtAuth(), app.UserBindEmailView)
}
